<template>
	<view class="wrap">
		<view class="">
			<view class="ding">
				<image src="@/static/bj/icon_indexSub_head.png" mode="aspectFill"></image>
			</view>
		</view>
		<uv-sticky offset-top="-50">
			<view class="fixed">
				<view class="btn" @click="goPages">
					马上拿钱
				</view>
			</view>
		</uv-sticky>
		<view class="list">
			<proList @goInfo="goInfo" v-if="list.length!=0" :list="list"></proList>
		</view>

	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow,
		onUnload,
		onPageScroll
	} from '@dcloudio/uni-app'
	import {
		getShopListv1,
		clickShop,
		clickGood,
		clickChannel
	} from '@/api/index.js'
	import {
		ref,
		onUnmounted,
		onMounted,
		getCurrentInstance

	} from 'vue';
	import proList from '@/components/list/list.vue'
	const {
		proxy
	} = getCurrentInstance()
	let flag = ref(false)
	onMounted(() => {

		init()
	})



	onUnmounted(() => {

	})

	onLoad((e) => {

	})

	let list = ref([])
	let pageData = ref({
		"pageSize": 20,
		"currentPage": 1
	})

	let init = async () => {

		let res = await getShopListv1(pageData.value)
		list.value = res.data
	}

	let goPages = (url) => {
		proxy.$ymmdBtn("moneyRight", {
			name: '马上拿钱'
		})
		console.log(uni.getStorageSync("token"), 'uni.getStorageSync("token")')
		if (uni.getStorageSync("token") == '') {
			uni.navigateTo({
				url: `/pages/index/index`
			})
		} else {
			uni.navigateTo({
				url: `/pagesC/list/index`
			})
		}
	}
	let goPage = (url) => {
		uni.navigateTo({
			url: `/pagesB/webview/webview?url=${url}`
		})
	}
	let goInfo = async (item) => {
		console.log(item,'item')
		proxy.$ymmdBtn("ymBtnPro",{
			name:'点击产品带id',
			id:item.id
		})
		goPage(item.h5url)
		let datass = {
			shopId: item.id
		}
		let p=await clickChannel(datass)
		return;
		console.log(item, 'item')
		proxy.$ymmdBtn("ymBtnPro", {
			name: '点击产品带id',
			id: item.id
		})
		let clickShopData = {
			shopId: item.id,
			type: item.openType
		}
		let ress = await clickShop(clickShopData)
		if (item.openType == 0) {
			goPage(item.h5url)
			// 连登
		} else if (item.openType == 1) {
			let data = {
				shopId: item.id,
				type: item.openType
			}
			let ll = await clickGood(data)
			if (ll.code == 100000) {
				let datass = {
					shopId: item.id
				}
				let p = await clickChannel(data)

			}
			goPage(ll.data.h5url)
		}
	}
</script>

<style lang="scss" scoped>
	.fixed {
		background:#FDDDB1;

	}

	.wrap {
		.list {
			padding: 0 24rpx;
			// height: 38vh;
			// overflow-y: scroll;
		}

		.ding {
			height: 600rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.btn {
			width: 80%;
			margin: 33rpx auto 33rpx auto;
			border-radius: 100rpx;
			line-height: 100rpx;
			font-size: 40rpx;
			color: #fff;
			text-align: center;
			background: linear-gradient(90deg, #FF8D4D 0%, #FF6145 100%);
			box-shadow: 0px 4px 15px 2px #FAC6A3;
		}

		width: 100%;
		// height: 100vh;
		background: #FDDDB1;
		border-radius: 0px 0px 0px 0px;
		background-size: 100% 100%;
	}
</style>